# Contributor: Mark Riedesel <mark@klowner.com>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=yaml-cpp
pkgver=0.7.0
pkgrel=0
pkgdesc="YAML parser and emitter in C++ matching YAML 1.2 spec"
url="https://github.com/jbeder/yaml-cpp"
arch="all"
license="MIT"
checkdepends="gtest-dev"
makedepends="cmake samurai"
subpackages="$pkgname-dev"
source="https://github.com/jbeder/yaml-cpp/archive/yaml-cpp-$pkgver.tar.gz
	fix-pkgconfig-and-cmake-install-dirs.patch
	enable-pic.patch
	unbundle-gtest.patch
	"
builddir="$srcdir/$pkgname-$pkgname-$pkgver"

prepare() {
	default_prepare

	# Remove bundled gtest.
	rm -rf test/gtest-*
}

build() {
	local _build_tests=ON
	if ! want_check; then
		_build_tests=OFF
	fi

	cmake -B build -G Ninja . \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_VERBOSE_MAKEFILE=ON \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DYAML_BUILD_SHARED_LIBS=ON \
		-DYAML_CPP_BUILD_TESTS=$_build_tests
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
2de0f0ec8f003cd3c498d571cda7a796bf220517bad2dc02cba70c522dddde398f33cf1ad20da251adaacb2a07b77844111f297e99d45a7c46ebc01706bbafb5  yaml-cpp-0.7.0.tar.gz
d1015982cc813cb6e6bb3ff991f4a6a6481c9d50bb991faf04974fac1dc65bf1be1d8d03c9fd11eb858d8add36be8bdcb2295e0059602bec438f67fe885d580a  fix-pkgconfig-and-cmake-install-dirs.patch
c9179e8dd0bdad1ca1a749f72cff14de923b1a5960287834fc0ab8dc068aa7222b740a103c100b5b63769349ffd5965f6b2ce843c8d3aa12ac4ba03e8457f389  enable-pic.patch
097623858f12200c444183d32763f6a0b1e723aa2e3ca6de229cc4616c4b7bd4d32f255fb650bf171a173e04d2639de7022b9ef19a48e13f713bad9b9f996a7c  unbundle-gtest.patch
"
